package net.modul.dict.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;
import net.common.manager.DictManager;
import net.common.service.GeneralService;
import net.modul.dict.service.DictDeleteService;
import net.modul.dict.service.DictEditorService;
import net.modul.dict.vo.DictSortVo;
import net.modul.dict.vo.DictVo;

/**
 * 数据字典请求处理类
 * 
 * @author 孙树林
 * 
 */
public class DictAction extends GeneralAction {

	private static final long serialVersionUID = 7741224840834710533L;

	private DictVo vo = new DictVo();
	private String key;
	private List<DictVo> dictList = new ArrayList<DictVo>();
	private List<DictSortVo> sortList = new ArrayList<DictSortVo>();

	public String searchDict() throws Exception {
		dictList = DictManager.getDict(key);
		return SUCCESS;
	}

	public String saveDict() throws Exception {
		GeneralService service = new DictEditorService();
		service.invoke();
		return SUCCESS;
	}

	public String editorDict() throws Exception {
		if(vo.getDict_num() != null) {
			vo = DictManager.getDictVo(vo.getDict_num());
		}
		return SUCCESS;
	}
	
	public String deleteDict() throws Exception {
		GeneralService service = new DictDeleteService();
		service.invoke();
		return SUCCESS;
	}

	public String searchDictSort() throws Exception {
		sortList = DictManager.getDictSort();
		return SUCCESS;
	}

	public List<DictVo> getDictList() {
		return dictList;
	}

	public List<DictSortVo> getSortList() {
		return sortList;
	}

	public DictVo getVo() {
		return vo;
	}

	public void setVo(DictVo vo) {
		this.vo = vo;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}
}
